package ar.com.mooral.activities;

import java.sql.Date;
import java.text.SimpleDateFormat;

import android.app.TabActivity;
import android.content.ComponentName;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TabHost;
import android.widget.TabHost.OnTabChangeListener;
import ar.com.mooral.crohn.application.CrohnContext;

public class Main extends TabActivity {

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.main);

		Resources res = getResources(); // Resource object to get Drawables
		final TabHost tabHost = getTabHost(); // The activity TabHost
		TabHost.TabSpec spec; // Resusable TabSpec for each tab
		Intent intent; // Reusable Intent for each tab

		// Create an Intent to launch an Activity for the tab (to be reused)

		intent = new Intent().setClass(this, TabMenuPrincipal.class);
//		tabHost.setTag("menu"); //////
		spec = tabHost.newTabSpec("menu").setIndicator("MENU",
				res.getDrawable(R.drawable.tab_home)).setContent(intent);
		tabHost.addTab(spec);

		intent = new Intent().setClass(this, TabMiEstado.class);
//		tabHost.setTag("mi_estado"); //////
		spec = tabHost.newTabSpec("mi_estado").setIndicator("MI ESTADO",
				res.getDrawable(R.drawable.tab_mi_estado)).setContent(intent);
		tabHost.addTab(spec);

		intent = new Intent().setClass(this, TabRegistros.class);
//		tabHost.setTag("registros"); //////
		spec = tabHost.newTabSpec("registros").setIndicator("REGISTROS",
				res.getDrawable(R.drawable.tab_registros)).setContent(intent);
		tabHost.addTab(spec);

		intent = new Intent().setClass(this, TabMedication.class);
//		tabHost.setTag("medicacion"); //////
		spec = tabHost.newTabSpec("medicacion").setIndicator("MEDICACION",
				res.getDrawable(R.drawable.tab_medicacion)).setContent(intent);
		tabHost.addTab(spec);

		intent = new Intent().setClass(this, TabMore.class);
//		tabHost.setTag("mas"); //////
		spec = tabHost.newTabSpec("mas").setIndicator("MAS",
				res.getDrawable(R.drawable.tab_mas)).setContent(intent);
		tabHost.addTab(spec);

		tabHost.setCurrentTab(0);


		/*
		int numberOfTabs = tabHost.getTabWidget().getChildCount();
		for(int t=0; t<numberOfTabs; t++){         
			tabHost.getTabWidget().getChildAt(t).setOnClickListener(new View.OnClickListener() {
				
				@Override
				public void onClick(View v) {
					String x = getTabHost().getCurrentTabTag();

				}
			});
		}
		*/
				
		/*
        tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
                public void onTabChanged(String arg0) {
                        int selectedTab = tabHost.getCurrentTab();
                }
        });
        */
		
        /*
		tabHost.setOnTabChangedListener(new OnTabChangeListener() {
			  public void onTabChanged(String arg0) {
				  if (CrohnContext.getLastClickedTab() == tabHost.getCurrentTab()) {
						Intent intent = new Intent();
						intent.setComponent(new ComponentName(MenuPrincipal.class.getPackage().getName(), MenuPrincipal.class.getName()));
					  
		         		TabGroupActivity parentActivity = (TabGroupActivity)getParent();
		         		parentActivity.startChildActivity("CalidadDeVida", intent);
				  } else {
					  CrohnContext.setLastClickedTab(tabHost.getCurrentTab());
				  }
			  }
		});  		
		*/
		
	}

}
